package com.lagou.consumer.controller;

import com.lagou.service.DemoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author xingyi
 */
@RestController
public class TestController {
    @DubboReference
    private DemoService demoService;

    private ExecutorService executorService = Executors.newCachedThreadPool();

    @GetMapping("/start")
    public String start() {
        executorService.submit(() -> {
            while (true) {
                executorService.submit(() -> demoService.methodA());
                executorService.submit(() -> demoService.methodB());
                executorService.submit(() -> demoService.methodC());
                Thread.sleep(30);
            }
        });
        return "ok";
    }
}
